#pragma once

#include "sfc/core/iter.h"
#include "sfc/core/num.h"

namespace sfc::ops {

struct Range {
  usize _start;
  usize _end;

 public:
  [[sfc_inline]] Range(usize start, Dummy) : _start{start}, _end{num::max_value<usize>()} {}

  [[sfc_inline]] Range(usize start, usize end) : _start{start}, _end{cmp::max(_start, end)} {}

  [[sfc_inline]] auto len() const -> usize {
    return _end - _start;
  }

  [[sfc_inline]] auto operator%(usize len) const -> Range {
    const auto a = _start < len ? _start : len;
    const auto b = _end < len ? _end : len;
    return Range{a, b};
  }
};

}  // namespace sfc::ops
